﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DoNet.SFExpress.Framework
{
    /// <summary>
    /// 接口统一返回结果
    /// </summary>
    public interface ISFResponse
    {
        /// <summary>
        /// API 平台异常信息
        /// </summary>
        string apiErrorMsg { get; set; }
        /// <summary>
        /// API 响应唯一号 UUID
        /// </summary>
        string apiResponseID { get; set; }
        /// <summary>
        /// API 平台结果代码
        /// </summary>
        string apiResultCode { get; set; }
    }

    /// <summary>
    /// 接口统一返回结果
    /// </summary>
    public class SFResponse : ISFResponse
    {
        /// <summary>
        /// API 平台异常信息
        /// </summary>
        public string apiErrorMsg { get; set; }
        /// <summary>
        /// API 响应唯一号 UUID
        /// </summary>
        public string apiResponseID { get; set; }
        /// <summary>
        /// API 平台结果代码
        /// </summary>
        public string apiResultCode { get; set; }
    }

    /// <summary>
    /// 顺丰API接口统一返回结果
    /// </summary>
    public class SFResponseApiResultData : SFResponse
    {
        /// <summary>
        /// 业务处理详细结果
        /// </summary>
        public string apiResultData { get; set; }
    }
    /// <summary>
    /// 顺丰AccessToken接口统一返回结果
    /// </summary>
    public class SFResponseAccessToken : SFResponse
    {
        /*
        apiResponseID	String(40)	Y	响应ID
        apiResultCode	String(10)	Y	响应码
        apiErrorMsg	String(200)	N	错误描述
        accessToken	String(100)	Y	
        expiresIn	Number	Y	
        */
        /// <summary>
        /// 访问令牌
        /// </summary>
        public string accessToken { get; set; }
        /// <summary>
        /// accessToken访问令牌过期时间，单位（秒）,默认7200秒。从申请成功后，开始倒计时7200s,令牌过期后（即expiresIn=0）需要重新获取 
        /// </summary>
        public long expiresIn { get; set; }
    }
    /// <summary>
    /// 顺丰箱单发票上传接口返回结果
    /// </summary>
    public class SFResponseFop
    {
        /// <summary>
        /// 是否成功
        /// 是
        /// Boolean
        /// </summary>
        public bool success { get; set; }
        /// <summary>
        /// 错误代码
        /// 否
        /// String
        /// </summary>
        public string errorCode { get; set; }
        /// <summary>
        /// 错误描述
        /// 否
        /// String
        /// </summary>
        public string errorMessage { get; set; }
        /// <summary>
        /// 业务对象
        /// 否
        /// Obj
        /// </summary>
        public IObjInfo obj { get; set; }
    }
    /// <summary>
    /// 顺丰图片回传接口返回结果
    /// </summary>
    public class SFResponseFis
    {
        /// <summary>
        /// 是否成功
        /// 是
        /// Boolean
        /// </summary>
        public bool success { get; set; }
        /// <summary>
        /// 错误代码
        /// 否
        /// String
        /// </summary>
        public string errorCode { get; set; }
        /// <summary>
        /// 错误描述
        /// 否
        /// String
        /// </summary>
        public string errorMessage { get; set; }
        /// <summary>
        /// 业务对象
        /// 否
        /// Obj
        /// </summary>
        public IObjInfo obj { get; set; }
    }

    public class ApiResultDataBase
    {
        /// <summary>
        /// 是否处理成功
        /// 是
        /// boolean
        /// </summary>
        public bool success { set; get; }
        /// <summary>
        /// 错误代码
        /// 否
        /// String
        /// </summary>
        public string errorCode { set; get; }
    }
    public class ApiResultDataErrorMessage : ApiResultDataBase
    {
        /// <summary>
        /// 错误信息
        /// 否
        /// String
        /// </summary>
        public string errorMessage { set; get; }
    }
    public class ApiResultDataErrorMsg : ApiResultDataBase
    {
        /// <summary>
        /// 错误信息
        /// 否
        /// String
        /// </summary>
        public string errorMsg { set; get; }
    }
    public class ApiResultDataMsg
    {
        /// <summary>
        /// 信息	
        /// 提示信息
        /// 否
        /// String(200)
        /// </summary>
        public string msg { set; get; }
        /// <summary>
        /// 状态码	
        /// 返回成功或失败信息(ok/fail)
        /// 是
        /// String(10)
        /// </summary>
        public string succ { set; get; }
    }
    public class ApiResultDataMessage
    {
        /// <summary>
        /// 响应结果：true 成功； false 失败
        /// 是
        /// boolean
        /// </summary>
        public bool success { set; get; }
        /// <summary>
        /// 结果描述
        /// 否
        /// String(1000)
        /// </summary>
        public string message { set; get; }
        /// <summary>
        /// 响应编码
        /// 是
        /// String(1000)
        /// </summary>
        public string code { set; get; }
    }

    /// <summary>
    /// 路由标签，除少量特殊场景用户外，其余均会返回
    /// </summary>
    public class RouteLabelInfo
    {
        /// <summary>
        /// 返回调用结果，1000：调用成功； 其他调用失败
        /// 是	
        /// String(30)
        /// </summary>
        public string code { get; set; }
        /// <summary>
        /// 路由标签数据详细数据，除少量特殊场景用户外，其余均会返回
        /// 是	
        /// </summary>
        public IRouteLabelData routeLabelData { get; set; }
        /// <summary>
        /// 失败异常描述
        /// 否	
        /// String(1000)
        /// </summary>
        public string message { get; set; }
    }

    public interface IRouteLabelData
    {

    }

    public class ObjInfo
    {
        /// <summary>
        /// 如 预入库成功、部分操作成功、短信发送成功
        /// </summary>
        public string msg { set; get; }
        /// <summary>
        /// 失败运单集合,success=true 时表示至少有一个运单成功，失败的运单信息放在 failList 中
        /// </summary>
        public List<FailResult> failList { set; get; }
        /// <summary>
        /// 
        /// </summary>
        public string sms_id { set; get; }
    }

    public class FailResult
    {
        /// <summary>
        /// 失败原因
        /// </summary>
        public string reason { set; get; }
        /// <summary>
        /// 运单号
        /// </summary>
        public string waybill_no { set; get; }
    }

    /// <summary>
    /// obj 接口类
    /// </summary>
    public interface IObjInfo
    {

    }
}
